using Gateway.Common.Entity;
using Gateway.Common.Enums;

namespace Gateway.Domain.Entities;

/// <summary>
/// 数据字典
/// </summary>
[PrimaryIdAttribute("DIC")]
public class DataDic : AggregateRootEntityBase
{
    /// <summary>
    /// 初始化
    /// </summary>
    /// <param name="name"></param>
    /// <param name="code"></param>
    /// <param name="value"></param>
    /// <param name="description"></param>
    /// <param name="sort"></param>
    /// <param name="parentId"></param>
    /// <param name="dicType"></param>
    public DataDic(string name = default, string code = default, string value = default, string description = default,
        int sort = default, string parentId = default, string dicType = default)
    {
        Name = name;
        Code = code;
        Value = value;
        Description = description;
        Sort = sort;
        ParentId = parentId ?? "";
        DicType = DataDicTypeEnum.FromValue(string.IsNullOrEmpty(dicType) ? DataDicTypeEnum.KeyValue.Value : dicType);
    }

    /// <summary>
    /// 更新
    /// </summary>
    /// <param name="name"></param>
    /// <param name="code"></param>
    /// <param name="value"></param>
    /// <param name="description"></param>
    /// <param name="sort"></param>
    public void Update(string name = default, string code = default, string value = default,
        string description = default,
        int sort = default)
    {
        Name = name;
        Code = code;
        Value = value;
        Description = description;
        Sort = sort;
    }

    /// <summary>
    /// 字典名称
    /// </summary>
    public string Name { get; private set; }

    /// <summary>
    /// 字典编码
    /// </summary>
    public string Code { get; private set; }

    /// <summary>
    /// 字典值
    /// </summary>
    public string Value { get; private set; }

    /// <summary>
    /// 描述
    /// </summary>
    public string Description { get; private set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Sort { get; private set; }

    /// <summary>
    /// 父级标识
    /// </summary>
    public string ParentId { get; private set; }

    /// <summary>
    /// 字典类别  category 类别  value 字典键值
    /// </summary>
    public DataDicTypeEnum DicType { get; private set; }

    public DataDic()
    {
    }
}